package cn.edu.swu.mys;

import java.util.Scanner;

public class Main {  // 改为大写 Main
    public static void main(String[] args) {  // 确保是小写 main
        Scanner scanner = new Scanner(System.in);
        ImageManager manager = new ImageManager();

        boolean running = true;

        while (running) {
            System.out.println("\n=== 网络图片下载与管理系统 ===");
            System.out.println("1. 下载图片");
            System.out.println("2. 查看已下载图片");
            System.out.println("3. 搜索图片");
            System.out.println("4. 退出");
            System.out.print("请输入功能编号: ");

            String choice = scanner.nextLine();

            switch (choice) {
                case "1": // 下载
                    System.out.print("请输入图片URL: ");
                    String url = scanner.nextLine();
                    manager.downloadImage(url);
                    break;
                case "2": // 查看
                    manager.listImages();
                    break;
                case "3": // 搜索
                    System.out.print("请输入图片名称: ");
                    String name = scanner.nextLine();
                    manager.searchImage(name);
                    break;
                case "4": // 退出
                    running = false;
                    System.out.println("已退出系统。");
                    break;
                default:
                    System.out.println("无效选项，请重新输入。");
            }
        }

        scanner.close();
    }
}